package Day09_Ex1_inheritence_poly;

import java.lang.reflect.Method;
import java.util.Iterator;

public class TestBikes
{
    public static void main(String[] args)
    {
        Bicycle bike01, bike02, bike03;
        RoadBike bike04;
        MountainBike bike05;
        
       //CREATING A BIKE STORE 
        BikeStore<Bicycle> bs1 = new BikeStore<Bicycle>();
        
        //ArrayBikeStore<Bicycle> bs1 = new ArrayBikeStore<Bicycle>();
        System.out.println("Generic Store Example");
        bs1.add(new Bicycle(20, 10,1));
        bs1.add(new MountainBike(20, 5, 200, "Triple"));
        bs1.add(new MountainBike(10, 30,6,"Single"));
        bs1.add(new MountainBike(7, 33,6,"Single"));
        bs1.add(new MountainBike(10, 55,34,"Dual"));
        bs1.add(new MountainBike(10, 30,24,"Single"));
        bs1.add(new RoadBike(10, 30,6,55));
        bs1.add(new MountainBike(10, 30,67,"Single"));
        bs1.add(new RoadBike(10, 30,6,60));
        bs1.add(new MountainBike(10, 30,6,"Single"));
        bs1.add(new MountainBike(5, 30,6,"Dual"));
        bs1.add(new MountainBike(10, 30,6,"Single"));
        
       // printAll(bs1);
        
        //USING BIKE STORE FOR SOMETHING ELSE
        BikeStore<MountainBike> bs2 = new BikeStore<MountainBike>();
        bs2.add(new MountainBike(20, 5, 200, "Triple"));
     //   printAll(bs2);
        
        
        //JAVA REFLECTION
        //getMethods
        Method[] methods = Bicycle.class.getMethods();

        for(Method method : methods){
            System.out.println("method = " + method.getName());
        }
        
        //get class details
        Class<Bicycle> myObjectClass = Bicycle.class;
        String className = myObjectClass.getName();
        System.out.println(className);
        
        //get package details
        System.out.println(myObjectClass.getPackage());
        
        System.out.println("****REVERSE ITERATOR****");
        
        Iterator<Bicycle> it = bs1.iterator(); //MMMMM, BUT WHICH ITERATOR ARE WE CALLING!
        while (it.hasNext())
        {
        		it.next().printDescription();
        }
        
        System.out.println("****CALL TO GENERIC PRINT****");
        printAll(bs1);
        
        
        System.out.println("CONTAINS EXAMPLE"); //NOTE THE BEHAVIOUR OUTPUT - CONTAINS USES THE ITERATOR!
        System.out.println("\nLooking for contains: " + bs1.contains(new MountainBike(10, 30,6,"Single")));
        System.out.println();
         
        System.out.println("TOARRAY EXAMPLE");
        Object[] a = bs1.toArray();
        for (Object bicycle : a) {
			((Bicycle) bicycle).printDescription();
		}
    }
     
    
    //public static void printAll(ArrayBikeStore<? extends Bicycle> b)
    public static void printAll(BikeStore<? extends Bicycle> b)
    {
    	System.out.println("*******\nGeneric printAll method Called\n*******");
    	for (int i = 0; i < b.size(); i++) {
        	b.get(i).printDescription(); 
		}
    }
//    
//    public static <T extends Bicycle> void printAll1 (T[] b)
//    {
//    	System.out.println("*******\nGeneric T printAll1 method Called\n*******");
//    	for (int i = 0; i < b.length; i++) {
//        	b[i].printDescription(); 
//        	
//		}
//    }
//    
//    public static <T extends Comparable<T>> int countGreaterThan(T[] anArray, T elem) {
//        int count = 0;
//        for (T e : anArray)
//        {
//        	if (e.compareTo(elem) > 0)
//                ++count;
//        	System.out.println("TESTING");
//        }
//        return count;
//    
    
    
}
